#ifndef ROUTER_H
#define ROUTER_H

#include <functional>
#include <memory>
#include "../protocol/protocol.h"
#include <map>
#include <hv/Channel.h>

class Router
{
public:

    // reisgter call back function
    void registerCallback(const std::string &args, std::function<void (std::shared_ptr<Protocol>, const hv::SocketChannelPtr&)> func);

    // invoke certain function
    const std::function<void (std::shared_ptr<Protocol>, const hv::SocketChannelPtr& channel)> &operator [](const std::string &args);
    const std::function<void (std::shared_ptr<Protocol>, const hv::SocketChannelPtr& channel)> &get(const std::string &args);
    Router();

private:
    std::map<std::string, std::function<void(std::shared_ptr<Protocol>, const hv::SocketChannelPtr& channel)>>routerMap;

};

#endif // ROUTER_H
